package com.xingzhi.common.constant;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * Created by daniel.luo on 2018/5/23.
 */
@Component
public class Const {
    /**
     * 七牛云
     */
    public static final String QINIU_TOKEN = "qiniu_token";
    public static final String AK = "-nvaC91bkR9iEOdvl7RWSpgM7I_S1vVnGPQ6bsoh";
    public static final String SK = "Ge0Ige_GvVaLZK7YUeMl0aDucf2b6MMlxmlxpGVV";
    public static String BUCKET_NAME;
    public static String DOMAIN;
    public static String PIPELINE;
    public static String NOTIFY;

    @Value("${spring.qiniu.bucket}")
    public void setBucketName(String bucketName) {
        BUCKET_NAME = bucketName;
    }

    @Value("${spring.qiniu.domain}")
    public void setDomain(String domain) {
        DOMAIN = domain;
    }

    @Value("${spring.qiniu.pipeline}")
    public void setPipeline(String pipeline) {
        PIPELINE = pipeline;
    }

    @Value("${spring.qiniu.notify}")
    public void setNotify(String notify) {
        NOTIFY = notify;
    }

    /**
     * 登陆token
     */
    public static final int NEW_TOKEN_LIFE = 60 * 60 * 24;
    public static final int WILL_DEAD = 60 * 5;

    /**
     * 默认1.0单节课听完评判标准
     */
    public static final double RATIO = 0.8;

    /**
     * 云片
     */
    public final static int V_CODE_EX_TIME = 320; // 稍长于前端（5min），不会造成前端还有剩余时间，后端却验证已过期的尴尬情况

    public final static String V_CODE_ALIVE = "5";

    public final static String E_CODE_THEME = "【行知教育】邮件验证码";

    /**
     * 微信登录
     */
    public final static String AUTHORIZATION_URL =
            "https://open.weixin.qq.com/connect/qrconnect?appid=%s&redirect_uri=%s&response_type=code&scope=%s&state=%s#wechat_redirect";

    public final static String ACCESSTOKE_OPENID_URL =
            "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";

    public final static String REFRESH_TOKEN_URL =
            "https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=%s&grant_type=refresh_token&refresh_token=%s";

    public final static String USER_INFO_URL =
            "https://api.weixin.qq.com/sns/userinfo?access_token=%s&openid=%s&lang=zh_CN";

    public final static String APP_ID = "wxb00fdd2efe79a6d8";
    public final static String APP_SECRET = "0428f505323b62746d9a6d1d64867e1a";
    public final static String SCOPE = "snsapi_login";
    public final static String WX_CALLBACK_LOGIN = "https://shwx.xingzhizx.com/wechat/login/auth";
    public final static String WX_CALLBACK_BIND = "https://shwx.xingzhizx.com/wechat/login/bind";

    /**
     * ElasticSearch
     */
    public static String CLUSTER_NAME;
    public static String CLUSTER_NODES;
    public static int CLUSTER_PORTS;
    public final static String QA_REP_INDEX = "qa_rep";
    public final static String QA_SOPTION_TYPE = "soption";//单选single option
    public final static String QA_MOPTION_TYPE = "moption";//多选multiple option
    public final static String QA_EQ_TYPE = "eq";//多选essay question
    public final static String COURSE_INDEX = "course_shot";
    public final static String COURSE_TYPE = "course";

    @Value("${elasticsearch.cluster-name}")
    public void setClusterName(String clusterName) {
        CLUSTER_NAME = clusterName;
    }

    @Value("${elasticsearch.cluster-nodes}")
    public void setClusterNodes(String clusterNode) {
        CLUSTER_NODES = clusterNode;
    }

    @Value("${elasticsearch.cluster-ports}")
    public void setClusterPort(int clusterPort) {
        CLUSTER_PORTS = clusterPort;
    }


}
